﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using HandyControl.Controls;
using HandyControl.Data;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using Zo.ExcelBox.Models;

namespace Zo.ExcelBox.ViewModels
{
    public partial class MainViewVM : ObservableObject
    {
        public ObservableCollection<FileItem> FileItems { get; } = new ObservableCollection<FileItem>();


        public ObservableCollection<SideMenuItem> SysMenus { get; set; } = new ObservableCollection<SideMenuItem>();

        /// <summary>
        /// 菜单选中事件
        /// </summary>
        public ICommand SideMenuChangedCommand => new RelayCommand<FunctionEventArgs<object>>(OnSideMenuChanged);



        /// <summary>
        /// 打开设置窗口
        /// </summary>
        public ICommand OpenSettingsCommand { get; }

        private readonly MainWindow _mainWindow;

        public MainViewVM(MainWindow mainWindow)
        {
            OpenSettingsCommand = new RelayCommand(OpenSettings);
            LoadData();
            _mainWindow = mainWindow;
        }

        private void LoadData()
        {
            FileItems.Add(new FileItem
            {
                Name = "Documents",
                IsFolder = true,
                Children = new ObservableCollection<FileItem>
            {
                new FileItem { Name = "resume.docx", IsFolder = false },
                new FileItem { Name = "report.pdf", IsFolder = false }
            }
            });

            FileItems.Add(new FileItem
            {
                Name = "Pictures",
                IsFolder = true,
                Children = new ObservableCollection<FileItem>
            {
                new FileItem { Name = "photo.jpg", IsFolder = false },
                new FileItem { Name = "logo.png", IsFolder = false }
            }
            });




            SysMenus = new ObservableCollection<SideMenuItem>()
            {
                 new SideMenuItem()
                 {
                      Name="菜单名称",
                      Header="才打2",
                      Tag="2"
                 }
            };
        }


        /// <summary>
        /// 打开设置窗口
        /// </summary>
        private void OpenSettings()
        {
            
        }



        void OnSelectedItemChanged()
        {

        }

        private void OnSideMenuChanged(FunctionEventArgs<object> e)
        {
            var item = e.Info as SideMenuItem;
            // 处理逻辑和 CodeBehind 一样
        }
    }
}
